package com.chandra.pos.order.dao.entity;


import com.chandra.pos.common.dao.AbstractAuditableEntity;
import com.chandra.pos.common.model.POSConstant;
import com.chandra.pos.common.utils.JodaDateTimeJsonSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created by Admin on 8/14/14.
 */
@Entity
@Table(name = "POS_ORDERS")
public class OrderEntity extends AbstractAuditableEntity {


    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ORDER_ID", unique = true, nullable = false)
    protected Long orderId;

    @Column(name = "ORDER_DATE", unique = false, nullable = true)
    @NotNull
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @JsonSerialize(using = JodaDateTimeJsonSerializer.class)
    @DateTimeFormat(pattern = POSConstant.APP_DATE_FORMAT)
    protected DateTime orderDate;

    @Column(name = "PAYMENT_DUE_DATE", unique = false, nullable = true)
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @JsonSerialize(using = JodaDateTimeJsonSerializer.class)
    @DateTimeFormat(pattern = POSConstant.APP_DATE_FORMAT)
    protected DateTime paymentDueDate;


    @Column(name = "EMPLOYEE_NAME", unique = false, nullable = true)
    protected String employeeName;

    @Column(name = "EMPLOYEE_ID", unique = false, nullable = true)
    protected String employeeId;


    @Column(name = "CUSTOMER_NAME", unique = false, nullable = true)
    protected String customerName;

    @Column(name = "CUSTOMER_ID", unique = false, nullable = true)
    protected Long customerId;

    @Column(name = "TOTAL_ORDER_AMOUNT", unique = false, nullable = true)
    protected Double totalOrderAmount;


    @Column(name = "ORDER_SUBTOTAL_AMOUNT", unique = false, nullable = true)
    protected Double orderSubTotalAmount;

    @Column(name = "ORDER_SHIPPING_AMOUNT", unique = false, nullable = true)
    protected Double orderShippingAmount;

    @Column(name = "ORDER_DISCOUNT", unique = false, nullable = true)
    protected Double orderDiscount;


    @Column(name = "ORDER_DUE_AMOUNT", unique = false, nullable = true)
    protected Double orderDueAmount;


    @Column(name = "COMMENTS", unique = false, nullable = true)
    private String comments;

    @Enumerated(EnumType.STRING)
    @NotNull
    private OrderStatus status;

    @Enumerated(EnumType.STRING)
    @NotNull
    private ShippingStatus shippingStatus;


    @Enumerated(EnumType.STRING)
    @NotNull
    private OrderType orderType;

    public OrderType getOrderType() {
        return orderType;
    }

    public void setOrderType(OrderType orderType) {
        this.orderType = orderType;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public DateTime getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(DateTime orderDate) {
        this.orderDate = orderDate;
    }

    public DateTime getPaymentDueDate() {
        return paymentDueDate;
    }

    public void setPaymentDueDate(DateTime paymentDueDate) {
        this.paymentDueDate = paymentDueDate;
    }

    public Double getTotalOrderAmount() {
        return totalOrderAmount;
    }

    public void setTotalOrderAmount(Double totalOrderAmount) {
        this.totalOrderAmount = totalOrderAmount;
    }

    public Double getOrderDueAmount() {
        return orderDueAmount;
    }

    public void setOrderDueAmount(Double orderDueAmount) {
        this.orderDueAmount = orderDueAmount;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public OrderStatus getStatus() {
        return status;
    }

    public void setStatus(OrderStatus status) {
        this.status = status;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public String getEmployeeName() {
        return employeeName;
    }

    public void setEmployeeName(String employeeName) {
        this.employeeName = employeeName;
    }

    public String getEmployeeId() {
        return employeeId;
    }

    public void setEmployeeId(String employeeId) {
        this.employeeId = employeeId;
    }

    public Double getOrderShippingAmount() {
        return orderShippingAmount;
    }

    public void setOrderShippingAmount(Double orderShippingAmount) {
        this.orderShippingAmount = orderShippingAmount;
    }

    public Double getOrderDiscount() {
        return orderDiscount;
    }

    public void setOrderDiscount(Double orderDiscount) {
        this.orderDiscount = orderDiscount;
    }

    public Double getOrderSubTotalAmount() {
        return orderSubTotalAmount;
    }

    public void setOrderSubTotalAmount(Double orderSubTotalAmount) {
        this.orderSubTotalAmount = orderSubTotalAmount;
    }

    public ShippingStatus getShippingStatus() {
        return shippingStatus;
    }

    public void setShippingStatus(ShippingStatus shippingStatus) {
        this.shippingStatus = shippingStatus;
    }
}
